<!--
* description: 非本品牌车辆维护
* author: dxuem
* createdDate: 2019-12-16
-->
<template>
  <div class="app-container app-container-table" >
    <crmGroupSubmit :formSubmitButton="formSubmitButton" />
    <el-form class="editPer filter-params-crm-scroll crm-s-scroll edit filter-params-crm" style="padding-bottom:20px;">
      <el-row>
        <el-col :span="2" id="crmaddcar">
          <el-button id="addcarbtn" @click="newCar" type="primary">添加车辆</el-button>
        </el-col>
      </el-row>
      <div v-for="(item,index) in dynamicTopic" :key="index">
        <div class="filter-container-crm filter-title-crm">车辆基本信息{{n-index}}</div>
        <el-row>
          <el-col :span="6">
            <el-form-item label="VIN码">
              <el-input type="text" v-model="item.vin" :disabled="item.disabled" placeholder="请输入"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="车辆品牌" clearable>
              <el-select
                v-model="item.carBrandCode"
                :disabled="item.disabled"
                :filterable="true"
                @change="getSeries(index)"
                placeholder="请选择"
              >
                <el-option
                  v-for="itemB in carOptions"
                  :key="itemB.compBrandCode"
                  :label="itemB.compBrandCn"
                  :value="itemB.compBrandCode"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="车系" clearable>
              <el-input
                v-model="item.carSeriesName"
                v-show="item.disabled"
                disabled
                placeholder="请输入">
              </el-input>
              <el-select
                v-model="item.carSeriesCode"
                v-show="!item.disabled"
                :disabled="item.disabled"
                @change="getType(index)"
                placeholder="请选择"
              >
                <el-option
                  v-for="itemS in item.serOptions"
                  :key="itemS.compCarseriesCode"
                  :label="itemS.compCarseriesName"
                  :value="itemS.compCarseriesCode"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="车型" clearable>
              <el-input
                v-model="item.carTypeName"
                v-show="item.disabled"
                disabled
                placeholder="请输入">
              </el-input>
              <el-select
                v-model="item.smallCarTypeCode"
                v-show="!item.disabled"
                :disabled="item.disabled"
                placeholder="请选择"
              >
                <el-option
                  v-for="itemT in item.typeOptions"
                  :key="itemT.compCartypeCode"
                  :label="itemT.compCartypeCn"
                  :value="itemT.compCartypeCode"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="车牌号">
              <el-input type="text" v-model="item.carLicenseNo" placeholder="请输入"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="车身颜色">
              <el-input
                type="text"
                v-model="item.carColorName"
                :disabled="item.disabled"
                placeholder="请输入"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="发动机号">
              <el-input
                type="text"
                v-model="item.engineNo"
                :disabled="item.disabled"
                placeholder="请输入"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="filter-container-crm filter-title-crm">车主关系{{n-index}}</div>
        <!-- <el-button size="small" @click="add(index)">新增</el-button> -->
        <el-button size="small" v-show="item.disabled" @click="add(index)">新增</el-button>
        <el-table
          :data="item.tableData"
          :stripe="flag"
          highlight-current-row
          @current-change="handleSelect"
          style="width: 100%;height:330px;overflow-x:auto"
          v-loading.body="listLoading"
          element-loading-text="Loading"
          border
          fit
        >
          <el-table-column type="index" label="序号" width="60"></el-table-column>
          <el-table-column label="操作" align="center">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                @click="handleEdit(scope.$index, scope.row,index)"
              >删除</el-button>
            </template>
          </el-table-column>
          <el-table-column
            v-for="tabl in colnames"
            :key="tabl.value"
            :label="tabl.label"
            :prop="tabl.value"
            :width="tabl.width"
            align="center"
          ></el-table-column>
        </el-table>
        <el-pagination
          background
          layout="prev, pager, next"
          :total="total"
          :page-size="pagesize"
          :current-page="pageindex"
          @prev-click="prev"
          @next-click="next"
          @current-change="changepage"
        ></el-pagination>
      </div>
    </el-form>
    <edit
      :dynamicEditRowData="editRowData"
      :popupsVisible="editPopupsVisible"
      :key="editPopupsKey"
      :popupsState="editPopupsState"
      @close="close"
    ></edit>
  </div>
</template>
<script>
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import { formMixins } from "@/components/mixins/formMixins";
import { crmApis } from "@/api/apiList/crm";
import { requestAPI } from "@/api/commonRequest";
export default {
  name: "editPer",
  // 组件混入对象
  mixins: [formMixins],
  components: {
    crmGroupForm: () =>
      import("@/components/crm/commonComponents/crmGroupForm"),
    crmGroupSubmit: () =>
      import("@/components/crm/commonComponents/crmGroupSubmit"),
    OneTableTemplate: () => import("@/components/crm/Template/crmformonePage"),
    edit: () => import("./useredit"),
    carSelect: () => import("./carSelect"),
    seriesSelect: () => import("./seriesSelect"),
    typeSelect: () => import("./typeSelect")
  },
  props: {},
  data() {
    return {
      carOptions: this.getBrand(),
      serOptions: this.getCarSer(),
      typeOptions: this.getCarType(),
      smallCarTypeCode: "",
      carBrandCode: "",
      carSeriesCode: "",
      compCarseriesId: "",
      seriesC: "",
      typeC: "",
      haddidsa: true,
      isShow: false,
      editPopupsKey: "",
      editPopupsState: "",
      editPopupsVisible: false,
      editRowData: {},
      states: "",
      holdCar: [
        {
          vin: "",
          compBrandCode: "",
          compCarseriesId: "",
          compCartypeCode: "",
          nationCode: "",
          carColorName: "",
          phone: ""
        }
      ],
      perbase: true,
      combase: false,
      n: 0,
      index: 0,
      sindex: 0,
      val: "",
      isdisplay: {
        ismuti: false
      },
      credit: false,
      // 保存API配置对象
      apiConfig: crmApis.createdOneIdMutationSaveCust, //客户信息-修改客户信息
      formSubmitButton: [
        {
          compKey: "buttonKey1",
          text: "修改关键信息",
          size: "small",
          type: "",
          clickEvent: () => this.edit(),
          isShow: false
        },
        {
          compKey: "buttonKey2",
          text: "保存",
          size: "small",
          type: "",
          clickEvent: () => this.save(),
          isShow: true
        }
      ],
      apiConfig: crmApis.custViewCustRelationQueryFindAll, //客户信息明细-联系人列表
      tableCols: [
        {
          prop: "controlBtn",
          label: "操作",
          codeField: "controlBtn",
          width: 70,
          align: "center",
          isComponent: true,
          comps: [
            {
              compKey: "propKey1",
              labelName: "修改",
              codeField: "editControlBtn",
              clickEvent: index => {
                this.edit(index);
              },
              component: () => import("@/components/org/linkButton"),
              align: "center"
            }
          ]
        },
        {
          prop: "custName",
          label: "客户名称",
          width: null,
          align: "center"
        },
        {
          prop: "phone",
          label: "电话",
          width: null,
          align: "center"
        },
        {
          prop: "custRelationName",
          label: "与车主关系",
          width: null,
          align: "center"
        },
        {
          prop: "relationTypeName",
          label: "人车关系类型",
          width: null,
          align: "center"
        },
        {
          prop: "dlrCustNo",
          label: "专营店客户ID",
          width: null,
          align: "center",
          hidden: true
        },
        {
          prop: "linkCustId", //联系人ID
          label: "linkCustId",
          width: null,
          align: "center",
          hidden: true
        },
        {
          prop: "custRelationCode",
          label: "关系描述编码",
          width: null,
          align: "center",
          hidden: true
        },
        {
          prop: "relationTypeCode",
          label: "联系人类别编码",
          width: null,
          align: "center",
          hidden: true
        },
        {
          prop: "isCarower",
          label: "是否车主编码",
          width: null,
          align: "center",
          hidden: true
        },
        {
          prop: "custFullName",
          label: "客户全称",
          width: null,
          align: "center",
          hidden: true
        },
        {
          prop: "custClassCode",
          label: "客户类型编码",
          width: null,
          align: "center",
          hidden: true
        }
      ],
      // 标题
      textMap: {
        edit: "维护个人客户",
        add: "新建个人客户"
      },
      bczz: Object,
      tableRows: [],
      rowData: {},
      flag: true,
      colnames: [
        { label: "客户名称", value: "custName" },
        { label: "电话", value: "phone" },
        { label: "与车主关系", value: "custRelationName" },
        { label: "人车关系类型", value: "relationTypeName" }
      ],
      tableData: [],
      listLoading: false,
      pagesize: 8,
      pageindex: 1,
      total: 0,
      dynamicTopic: [],
      formField: {
        dlrCustNo: ""
      },
      sindex: "",
      vin: "",
      dlrCustNo: this.$route.params.dlrCustNo,
      idCardPath: "",
      driveCardPath: "",
      drivingCardPath: "",
      jsnum:0
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.initdata(this.$route.params.dlrCustNo);
      this.bczz = this.$route.params.hZZ;
    });
  },
  methods: {
    // 车辆品牌
    getBrand: function(index) {
      let that = this;
      let queryObj = {
        // api配置
        apiConfig: crmApis.mdmCompBrandQueryFindAll,
        // 需要调用的API服务配置
        apiServices: [
          {
            //表格中台返回网格的字段
            apiQueryRow: ["compBrandCode", "compBrandCn"]
          }
        ],
        //条件/实体参数（变量），根据typeParam中的定义配置
        variables: {
          pageSize: -1,
          pageIndex: 1,
          //当前中台使用的名称有dataInfo、info，具体查看API文档
          dataInfo: {
            isEnable: "1"
          } //值列表编码
        }
      };
      let paramD = that.$getParams(queryObj);
      // 调用中台API方法（可复用）
      requestAPI(paramD).then(response => {
        if (
          response.data[queryObj.apiConfig.ServiceCode].result == "1"
          //&&response.data[queryObj.apiConfig.ServiceCode].rows != ""
        ) {
          that.carOptions = response.data[queryObj.apiConfig.ServiceCode].rows;
        }
      });
      // that.value =that.dynamicTopic[index].carBrandCode;
    },
    // 车型
    getCarType: function(index, pcode) {
      let that = this;
      let parent = this.$utils.getHasFormFieldParentComponent(this);
      if(parent.typeC!=undefined)
      {
        this.pcode = parent.typeC;
      }
      else{
        this.pcode=""
      }
      let queryObj = {
        // api配置
        apiConfig: crmApis.mdmCompCarTypeQueryFindAll,
        // 需要调用的API服务配置
        apiServices: [
          {
            //表格中台返回网格的字段
            apiQueryRow: ["compCartypeCn", "compCartypeCode"]
          }
        ],
        //条件/实体参数（变量），根据typeParam中的定义配置
        variables: {
          pageSize: -1,
          pageIndex: 1,
          //当前中台使用的名称有dataInfo、info，具体查看API文档
          dataInfo: { compCarseriesId: pcode,isEnable: "1" } //值列表编码
        }
      };
      let paramD = that.$getParams(queryObj);
      // 调用中台API方法（可复用）
      requestAPI(paramD).then(response => {
        if (
          response.data[queryObj.apiConfig.ServiceCode].result == "1"
          //&&response.data[queryObj.apiConfig.ServiceCode].rows != ""
        ) {
          if(index!=undefined)
          {
            that.dynamicTopic[index].typeOptions = response.data[queryObj.apiConfig.ServiceCode].rows;
          }else{
            that.typeOptions=response.data[queryObj.apiConfig.ServiceCode].rows;
          }
        }
      });
      // this.value=that.dynamicTopic[index].smallCarTypeCode
    },
    // 车系
    getCarSer: function(index, pcode) {
      let that = this;
      let parent = this.$utils.getHasFormFieldParentComponent(this);
      if(parent.seriesC!=undefined)
      {
        this.dataInf = parent.seriesC;
      }
      else{
        this.dataInf=""
      }
      let queryObj = {
        // api配置
        apiConfig: crmApis.mdmCompCarSeriesQueryFindAll,
        // 需要调用的API服务配置
        apiServices: [
          {
            //表格中台返回网格的字段
            apiQueryRow: [
              "compCarseriesName",
              "compCarseriesCode",
              "compCarseriesId"
            ]
          }
        ],
        //条件/实体参数（变量），根据typeParam中的定义配置
        variables: {
          pageSize: -1,
          pageIndex: 1,
          //当前中台使用的名称有dataInfo、info，具体查看API文档
          dataInfo: { compBrandCode: pcode,isEnable: "1" } //值列表编码
        }
      };
      let paramD = that.$getParams(queryObj);
      // 调用中台API方法（可复用）
      requestAPI(paramD).then(response => {
        if (
          response.data[queryObj.apiConfig.ServiceCode].result == "1"
          //&&response.data[queryObj.apiConfig.ServiceCode].rows != ""
        ) {
          if(index!=undefined)
          {
            that.dynamicTopic[index].serOptions = response.data[queryObj.apiConfig.ServiceCode].rows;
          }
          else{
            that.serOptions=response.data[queryObj.apiConfig.ServiceCode].rows;
          }
        }
      });
      // this.value=that.dynamicTopic[index].carSeriesCode
    },
    // 查询车辆信息
    initdata(dlrCustNo) {
      let that = this;
      let queryObj = {
        type: "query",
        apiConfig: crmApis.custViewCustCarListQueryFindAll, //客户信息明细-车辆关系
        apiServices: [
          {
            apiQueryRow: [
              "relationTypeName",
              "carBrandCode",
              "carBrandName",
              "vin",
              "engineNo",
              "carLicenseNo",
              "carSeriesCode",
              "carSeriesName",
              "carTypeCode",
              "carTypeName",
              "carColorCode",
              "carColorName",
              "saleDate",
              "bindDate",
              "mileage",
              "lastRepairDate"
            ]
          }
        ],
        variables: {
          dataInfo: {
            dlrCustNo: dlrCustNo,
            isCurBrand: "0"
          }
        }
      };
      var paramD = that.$getParams(queryObj);
      requestAPI(paramD).then(response => {
        if (response.data[queryObj.apiConfig.ServiceCode].result == "1") {
          let results = response.data[queryObj.apiConfig.ServiceCode].rows;
          for (let i = 0; i < results.length; i++) {
            let hadCar = {
              vin: results[i].vin,
              carBrandName: results[i].carBrandName,
              carBrandCode: results[i].carBrandCode,
              engineNo: results[i].engineNo,
              carLicenseNo: results[i].carLicenseNo,
              carSeriesCode: results[i].carSeriesCode,
              carSeriesName: results[i].carSeriesName,
              carTypeCode: results[i].carTypeCode,
              carTypeName: results[i].carTypeName,
              carColorCode: results[i].carColorCode,
              carColorName: results[i].carColorName,
              saleDate: results[i].saleDate,
              bindDate: results[i].bindDate,
              mileage: results[i].mileage,
              lastRepairDate: results[i].lastRepairDate,
              smallCarTypeCode: results[i].carTypeCode,
              disabled: true,
            };
            let brandR = "brand" + i;
            for (let key in that.$refs) {
              if (key == brandR) {
                that.$refs[key][0].getData();
              }
            }
            let seriesR = "series" + i;
            for (let key in that.$refs) {
              if (key == seriesR) {
                that.$refs[key][0].getData();
              }
            }
            let typeR = "type" + i;
            for (let key in that.$refs) {
              if (key == typeR) {
                that.$refs[key][0].getData();
              }
            }
            // this.dynamicTopic.push(hadCar);
            this.n++;
            this.queryRela(dlrCustNo, results[i].vin, hadCar);
          }
        } else {
          that.$crmcf.showMessages(
            that,
            "error",
            response.data[queryObj.apiConfig.ServiceCode].msg
          );
        }
      });
      this.formField.dlrCustNo = this.$route.params.dlrCustNo;
    },
    // 初始化人车关系
    queryRela(dlrCustNo, vin, hadCar) {
      let that = this;
      let queryObj = {
        type: "query",
        apiConfig: crmApis.custViewCustRelationQueryFindAll, //客户信息明细-联系人列表
        apiServices: [
          {
            apiQueryRow: [
              "dlrCustNo", //
              "custName",
              "phone",
              "custRelationName",
              "relationTypeName",
              "dlrCustNo",
              "linkCustId",
              "custRelationCode",
              "relationTypeCode",
              "isCarower",
              "custFullName",
              "custClassCode",
              "vin"
            ]
          }
        ],
        variables: {
          dataInfo: {
            dlrCustNo: dlrCustNo,
            vin: vin
          }
        }
      };
      var paramD = that.$getParams(queryObj);
      requestAPI(paramD).then(response => {
        if (response.data[queryObj.apiConfig.ServiceCode].result == "1") {
          let rowData = response.data[queryObj.apiConfig.ServiceCode].rows;
          hadCar.tableData = rowData;
          let tabRows = [];
          let paramsRow = {
            custName: "",
            custFullName: "",
            phone: "",
            custRelationCode: "",
            relationTypeCode: "",
            dlrCustNo: "",
            custClassCode: "", //客户类型,
            linkCustId:""
          };
          for (let i = 0; i < rowData.length; i++) {
            for (let key in paramsRow) {
              if (rowData[i].hasOwnProperty(key)) {
                paramsRow[key] = rowData[i][key];
              }
            }
            tabRows.push(paramsRow);
          }
          hadCar.tableRows = tabRows;
          hadCar.vin = vin;
          // hadCar.tableRows = response.data[queryObj.apiConfig.ServiceCode].rows;
          this.dynamicTopic.unshift(hadCar);
        }
      });
    },
    //保存
    save() {
      let that = this;
      for (var i = 0; i < that.dynamicTopic.length; i++) {
        //格式校验
        //必填校验
        var html = "";
        let valid = true;
        if (that.dynamicTopic[i].vin == "") {
          html = html + `<div>VIN码不能为空</div>`;
        }
        if (that.dynamicTopic[i].carBrandCode == "") {
          html = html + `<div>车辆品牌不能为空</div>`;
        }
        if (html != "") {
            this.$crmcf.showMessages(this, 'error', html, true)
          valid = false;
          break;
        }
        if (this.dynamicTopic[i].vin.length != 17) {
          that.$notify.error({
            title: "校验项",
            message: "VIN码长度为17位"
          });
          valid = false;
          break;
        }
        let vailds = true;
        let vaildParams = {
          carLicenseNo: [
            "carBand",
            this.dynamicTopic[i].carLicenseNo,
            `<div>请输入正确的车牌号</div>`
          ]
        };
        vailds = this.$crmcf.regex(this, vaildParams);
        if (!vailds) {
          return;
        }
        if (valid) {
          let queryObj = {
            type: "mutation",
            apiConfig: crmApis.createdOneIdMutationSaveCust, //专营店客户信息-新增客户
            variables: {
              dataInfo: {
                custModifyScence: "309", //场景编码--4S新增用车人
                carInfo: {
                  vin: that.dynamicTopic[i].vin,
                  carBrandCode: that.dynamicTopic[i].carBrandCode,
                  engineNo: that.dynamicTopic[i].engineNo,
                  carSeriesCode: that.dynamicTopic[i].carSeriesCode,
                  smallCarTypeCode: that.dynamicTopic[i].smallCarTypeCode,
                  carLicenseNo: that.dynamicTopic[i].carLicenseNo,
                  carColorCode: that.dynamicTopic[i].carColorCode,
                  carColorName: that.dynamicTopic[i].carColorName
                },
                custInfo: {
                  dlrCustNo: that.formField.dlrCustNo //车主客户编码
                },
                // 联系人客户编码
                // custInfoRelationList: that.dynamicTopic[i].tableRows
              }
            }
          };
          var paramD = that.$getParams(queryObj);
          requestAPI(paramD).then(response => {
            if (response.data[queryObj.apiConfig.ServiceCode].result == "1") {
              that.jsnum+=1;
              if(that.jsnum==that.dynamicTopic.length)
              {
                that.$crmcf.showMessages(that, "success", "保存成功！");
                that.jsnum=0
                that.bczz.$refs.multipleTable.queryTable();
                that.$crmcf.crmcloseView(that);
              }
            } else {
              that.$crmcf.showMessages(
                that,
                "error",
                response.data[queryObj.apiConfig.ServiceCode].msg
              );
            }
          });
        }
      }
    },
    saveForm() {
      //保存表单
      let that = this;
      // that.handleChange(param);

      this.formField.custFullName = this.formField.custName;
      let results = this.formField;
      for (let key in this.saveformField) {
        if (results.hasOwnProperty(key)) {
          this.saveformField[key] = results[key];
        }
      }
      this.saveformField.dlrCustNo = this.$route.params.dlrCustNo;
      this.saveformField.addrProvince = this.formField.provinceName;
      this.saveformField.addrCity = this.formField.cityName;
      this.saveformField.addrCounty = this.formField.countyName;
      this.saveformField.custClassCode = "0";
      this.saveformField.isHaveChild = this.formField.isHaveChildCode;
      this.saveformField.webchat = this.formField.openId;

      let custModifyScence = "";
      if (this.$route.params.status == "edit") {
        custModifyScence = "303";
      } else if (this.$route.params.status == "add") {
        custModifyScence = "301";
      }
      let queryObj = {
        // api配置
        type: "mutation",
        apiConfig: crmApis.createdOneIdMutationSaveCust, //客户信息-修改
        //条件/实体参数（变量），根据typeParam中的定义配置
        variables: {
          //当前中台使用的名称有dataInfo、info，具体查看API文档
          dataInfo: {
            custModifyScence: custModifyScence, //场景编码--修改客户信息
            custInfo: this.saveformField
          }
        }
      };

      //转换了中台请求格式数据
      var paramD = that.$getParams(queryObj);
      // 调用中台API方法（可复用）
      requestAPI(paramD).then(response => {
        if (
          response.data[queryObj.apiConfig.ServiceCode].result == "1"
          // &&response.data[queryObj.apiConfig.ServiceCode].rows != ""
        ) {
          that.uploadFiles("1", that.idCardPath);
          that.uploadFiles("2", that.driveCardPath);
          that.uploadFiles("3", that.drivingCardPath);
          that.$crmcf.showMessages(that, "success", "保存成功！");
          that.$crmcf.crmcloseView(that);
        } else {
          that.$crmcf.showMessages(
            that,
            "error",
            response.data[queryObj.apiConfig.ServiceCode].msg
          );
        }
      });
    },
    basecustClass(val) {
      let that = this;
      if (val == "0") {
        that.perbase = true;
        that.combase = false;
      } else {
        that.perbase = false;
        that.combase = true;
      }
    },
    newCar() {
      let that = this;
      this.dynamicTopic.unshift({
        vin: "",
        carBrandCode: "",
        carSeriesCode: "",
        compBrandCode: "",
        compCarseriesId: "",
        compCartypeCode: "",
        smallCarTypeCode: "",
        nationCode: "",
        carColorName: "",
        phone: "",
        tableRows: [],
        tableData: [],
        serOptions: [],
        typeOptions: []
      });
      this.getCarSer(0),
        this.getCarType(0),
        // for (let key in that.$refs) {
        //   if (key == seriesR) {
        //     that.$refs[key][0].value = "";
        //   }
        // }

        // for (let key in that.$refs) {
        //   if (key == typeR) {
        //     that.$refs[key][0].value = "";
        //   }
        // }
        this.n++;
      setTimeout(this.resetCar(), 100);
    },
    resetCar() {
      let that = this;
      let brandR = "brand" + (this.n - 1);
      let seriesR = "series" + (this.n - 1);
      let typeR = "type" + (this.n - 1);
      for (let key in that.$refs) {
        if (key == brandR) {
          that.$refs[key][0].value = "";
        }
        if (key == seriesR) {
          that.$refs[key][0].value = "";
        }
        if (key == typeR) {
          that.$refs[key][0].value = "";
        }
      }
    },
    add(index) {
      this.editRowData = {};
      this.editRowData.index = index;
      this.index = index;
      this.showEdit("add");
    },
    // 新增回显
    queryadd(dlrCustNo,vin,index){
      let that=this
      let queryObj = {
            type: "query",
            apiConfig: crmApis.custViewCustRelationQueryFindAll, //客户信息明细-联系人列表
            apiServices: [
          {
            apiQueryRow: [
              "dlrCustNo", //
              "custName",
              "phone",
              "custRelationName",
              "relationTypeName",
              "linkCustId",
              "custRelationCode",
              "relationTypeCode",
              "isCarower",
              "custFullName",
              "custClassCode",
              "vin"
            ]
          }
        ],
            variables: {
              dataInfo: {
                dlrCustNo: dlrCustNo,
                vin: vin
              }
            }
          };
          var paramD = that.$getParams(queryObj);
          requestAPI(paramD).then(response => {
            if (response.data[queryObj.apiConfig.ServiceCode].result == "1") {
              let rowData = response.data[queryObj.apiConfig.ServiceCode].rows;
              this.dynamicTopic[index].tableData=rowData
              this.dynamicTopic[index].tableRows=rowData
            } else {
              that.$crmcf.showMessages(
                that,
                "error",
                response.data[queryObj.apiConfig.ServiceCode].msg
              );
            }
          });
    },
    handleEdit(sindex, row, index){
      let that=this
      // that.dynamicTopic[index].tableData.splice(sindex, 1);
      let linkCustId=that.dynamicTopic[index].tableRows[sindex].linkCustId;
      let queryObj = {
            type: "mutation",
            apiConfig: crmApis.mdmDlrCustRelationMutationDelete, //联系人删除
            variables: {
              dataInfo: {
                linkCustId:linkCustId
              }
            }
          };
          var paramD = that.$getParams(queryObj);
          requestAPI(paramD).then(response => {
            if (response.data[queryObj.apiConfig.ServiceCode].result == "1") {
              that.$crmcf.showMessages(that, "success", "删除成功！");
              this.queryadd(this.formField.dlrCustNo,that.dynamicTopic[index].vin,index)
              // that.dynamicTopic[index].tableData.splice(sindex, 1);
            } else {
              that.$crmcf.showMessages(
                that,
                "error",
                response.data[queryObj.apiConfig.ServiceCode].msg
              );
            }
          });
    },
    showEdit(type) {
      this.editPopupsState = type;
      this.editPopupsVisible = true;
      this.editPopupsKey = this.$utils.generateId();
    },
    // handleEdit(sindex, row, index) {
    //   let that = this;
    //   this.editRowData = row;
    //   this.editRowData.index = index;
    //   this.editRowData.sindex = sindex;
    //   this.sindex = sindex;
    //   this.editRowData.vin = this.dynamicTopic[index].vin;
    //   this.editRowData.carBrandCode = this.dynamicTopic[index].carBrandCode;
    //   this.index = index;
    //   this.showEdit("edit");
    //   // this.$emit("clickedit", row);
    // }, //scope.row包含整行数据
    handleDelete(index, row) {
      console.log(index, row);
    },
    handleSelect: function(row) {
      let that = this;
      console.log(row);
      that.rowData = row;
    },
    selectView: function() {
      let _this = this;
      _this.$emit("selectView", 1);
    },
    prev(index) {
      let that = this;
      that.pageindex = index;
      this.getData();
    },
    next(index) {
      let that = this;
      that.pageindex = index;
      this.getData();
    },
    changepage(index) {
      let that = this;
      that.pageindex = index;
      this.getData();
    },
    getSeries(index) {
      let that = this;
      console.log(this.dynamicTopic[index].carBrandCode);
      let Bcode = this.dynamicTopic[index].carBrandCode;
      this.dynamicTopic[index].carSeriesCode=''
      this.dynamicTopic[index].smallCarTypeCode=''
      this.getCarSer(index, Bcode);
      // that.seriesC = this.val;
      // let seriesR = "series" + index;
      // for (let key in that.$refs) {
      //   if (key == seriesR) {
      //     that.$refs[key][0].getData();
      //   }
      // }
    },
    getType(index) {
      let that = this;
      let Scode = this.dynamicTopic[index].carSeriesCode;
      let seriesId = "";
      let Opt = this.dynamicTopic[index].serOptions;
      for (let i = 0; i < Opt.length; i++) {
        if (Opt[i].compCarseriesCode == Scode) {
          seriesId = Opt[i].compCarseriesId;
        }
      }
      this.dynamicTopic[index].smallCarTypeCode=''
      this.getCarType(index, seriesId);
      //   that.typeC = this.val;
      //   let typeR = "type" + index;
      //   for (let key in that.$refs) {
      //     if (key == typeR) {
      //       that.$refs[key][0].getData();
      //     }
      //   }
    }
  }
};
</script>
<style scoped>
#crmaddcar {
  padding-left: 1%;
}
.choosefile {
  float: left;
  text-align: left;
}
.filter-params-crm .el-col label {
  width: 32%;
}
.newOrder {
  margin-bottom: 2%;
}
</style>
